package com.hy.cloud.order.service;

import com.hy.cloud.order.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class UserRpcService {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 根据用户ID获取用户信息
     *
     * @param userId 用户ID
     * @return 用户信息
     */
    public User getUserById(Long userId) {
        String url = "http://localhost:10100/api/user/findUserByUserId/" + userId;
        return restTemplate.getForObject(url, User.class);
    }
}